# 存量商户增终
import xlrd
import json
import requests


def read_excel_test(excelname, sheename, row, url):
    wb = xlrd.open_workbook(excelname)
    sheet_1 = wb.sheet_by_name(sheename)
    col = sheet_1.ncols
    title = {}
    for i in range(0, col):
        sheet_1.cell(0, i).value
        title[i] = sheet_1.cell(0, i).value
    print(title)
    for i in range(1, row):
        excel_row = {}
        for j in range(0, col):
            excel_row[title[j]] = sheet_1.cell(i, j).value
        print(excel_row)
    request_json ={"sysId": excel_row["I_sysId"],"orderId": excel_row["I_orderId"]}
    json_str = json.dumps(request_json, ensure_ascii=False)
    url1 = url + json_str + '}'
    result = requests.get(url1)
    print(url1)
    print(result.content.decode('utf-8'))



if __name__ == '__main__':
    excelname = 'stockPosRegister.xlsx'
    sheename = 'stockPosRegister'
    row = 2
    url = 'http://192.168.32.14:9456/rpc.json?_service=http://service.huifu.com/nsposmas/fposBankPosRegService_1.0.0&_method=stockPosRegister&_param={"stockBankPosRegRequest":'
    read_excel_test(excelname, sheename, row, url)
